﻿@page "/lifecycle"

<h3>LifeCycle</h3>

<button @onclick="Refresh">刷新</button>

@inject ILogger<LifeCycle> Logger

@code {
    public override Task SetParametersAsync(ParameterView parameters)
    {
        Logger.LogInformation(nameof(SetParametersAsync));
        return base.SetParametersAsync(parameters);
    }

    protected override void OnInitialized()
    {
        Logger.LogInformation(nameof(OnInitialized));
        base.OnInitialized();
    }

    protected override Task OnInitializedAsync()
    {
        Logger.LogInformation(nameof(OnInitializedAsync));
        return base.OnInitializedAsync();
    }

    protected override void OnParametersSet()
    {
        Logger.LogInformation(nameof(OnParametersSet));
        base.OnParametersSet();
    }

    protected override Task OnParametersSetAsync()
    {
        Logger.LogInformation(nameof(OnParametersSetAsync));
        return base.OnParametersSetAsync();
    }

    protected override void OnAfterRender(bool firstRender)
    {
        Logger.LogInformation($"{nameof(OnAfterRender)}({firstRender})");
        base.OnAfterRender(firstRender);
    }
    protected override Task OnAfterRenderAsync(bool firstRender)
    {
        Logger.LogInformation($"{nameof(OnAfterRenderAsync)}({firstRender})");
        return base.OnAfterRenderAsync(firstRender);
    }

    void Refresh()
    {
        Logger.LogInformation($"点击了按钮");
        StateHasChanged();
    }
}
